//Subject.java
package memento.whitebox;

/**
 *@author:youtubezou
 *@version:2012-8-16
 */
public class Subject
{
	private String state = "Init";
	private MementoKeeper stateKeeper = new MementoKeeper();
	
	public Subject saveState()
	{
		stateKeeper.pushMemento(new Memento(state));
		return this;
	}

	public Subject restoreState()
	{
		this.state = (String) stateKeeper.popMemento().getState();
		return this;
	}
	
	public Subject changeState(String newState)
	{
		this.state = newState;
		return this;
	}
	
	public String getState()
	{
		return state;
	}
	
	public String toString()
	{
		return state;
	}
}
